package technology;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class JsonOrg {

	/**
	 * @param args
	 * @throws JSONException 
	 */
	public static void main(String[] args) throws JSONException {
		test1();

	}
	
	public static void test1() throws JSONException{
		//{"point":{"x":10,"y":20,"name":"hello"}}
		String string="{\"point\":{\"x\":10,\"y\":20,\"name\":\"hello\"}}";
		JSONObject json=new JSONObject(string);
		JSONObject point=json.getJSONObject("point");
		System.out.println(point.getString("name")+"--"+point.getInt("x")+"--"+point.getInt("y"));
		//{"name":["one","two","three"]}
		string="{\"name\":[\"one\",\"two\",\"three\"]}";
		json=new JSONObject(string);
		JSONArray jsonArray=json.getJSONArray("name");
		for(int i=0;i<jsonArray.length();i++)
			System.out.println("array"+jsonArray.getString(i));
		
	}

}
